﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace GameGo.Attribute
{
    public class isAuthorizeAttribute : AuthorizeAttribute
    {
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            var currentUser = httpContext.Session["UserName"];
            return currentUser != null;
        }
        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            ContentResult cr = new ContentResult();
            cr.Content = "<script>window.location.href='../../Home/Index'</script>";
            filterContext.Result = cr;
        }
    }
}